<?php
namespace  plugin\banmitongcheng\admin; 
use  plugin\banmitongcheng\model\PluginBanmiTongchengSet; 
use  plugin\banmitongcheng\validate\TongchengsetValidate;
use app\admin\common\Baseadmin;
use think\facade\Db;
use think\Request;
class Tongchengset extends Baseadmin
{
       
      /**
      * @notes  商家设置 
      * @variable  id=; 
      * @date 2022-12-05 20:05:16
      * @author 半米科技低代码一键生成
      */
      public function   finds_sjsz(){  
             $request= (new TongchengsetValidate())->IsCheck();
             $field="id,shop_name,shop_describe,shop_search_placeholder,lbs_sing,home_img,create_time,update_time,is_check_pay,is_check_examine,wx_appid,wx_secret,wx_mch_id,wx_mch_key,top_price";
 
             
             
             $map=[
                  ['id',	'=' ,	'1'],
                  ];
             $model =(new PluginBanmiTongchengSet())->finds($map,$field);
             
             
             $data['find']=$model;
             $data['find_sc']=Db::name('plugin_banmi_tongcheng_statistics')->where('id',1)->find();;
             
             
             
             ajaxmsg('ok', 200,$data);  
      }
       
      /**
      * @notes  设置同城信息 
      * @variable  id=;shop_name=名称;shop_describe=名称;shop_search_placeholder=搜索描述;lbs_sing=腾讯地图秘钥;home_img=图片; 
      * @date 2022-12-08 21:57:35
      * @author 半米科技低代码一键生成
      */
      public function   updates_sztcxx(){  
             $request= (new TongchengsetValidate())->IsCheck('sztcxx');
             $field=["shop_name","shop_describe","shop_search_placeholder","lbs_sing","home_img","create_time","update_time","is_check_pay","is_check_examine","wx_secret","wx_appid" ,"wx_mch_id","wx_mch_key","top_price" ];
             $request['create_time']= time();
             $request['update_time']=  time();
             $request['top_price']=$request['top_price']*100;
             $map=[
                  ['id',	'=' ,	'1'],
                  ];
             $model =(new PluginBanmiTongchengSet())->updates($map,$request,$field);
             
             $home_pl='bantongchengshop';
             $lbs_sing = input("request.lbs_sing");
             if ($lbs_sing) {
                 ismapkey($home_pl,$lbs_sing);
             } 
             $shop_read = input("request.shop_read");
             $shop_num = input("request.shop_num");
             
             Db::name('plugin_banmi_tongcheng_statistics')->where('id', 1)->update(['shop_read' => $shop_read  , 'shop_num' => $shop_num ]);
            
              if($model){
               ajaxmsg('设置成功', 200,$request);
              }
               ajaxmsg('更新失败', 0);  
      }
      //控制器方法
    
    
    
}